<template>
	<view class="container">
		<view class="contract-container border-line">
			<view class="contract-title">
				{{contentTitle}}
			</view>
			<view class="content border-line">
				<u-read-more ref="uReadMore" :toggle="true" closeText="展开" showHeight="120" color="#1BC46D">
					<rich-text :nodes="content"></rich-text>
				</u-read-more>
			</view>
		</view>
		<view class="sign-container border-line">
			乙方签字：
			<u--image width="268rpx" height="130rpx" :src="signImage" v-model="aspectFit"></u--image>
		</view>
		<view class="date-container">
			签署时间：{{date}}
		</view>
	</view>
</template>

<script>
	import {findContract} from "@/api/api.js"
	export default {
		data() {
			return {
				contentTitle:"合同条款一",
				content:"合同条款一合同条款一合同条款一",
				signImage:"",
				date:'',
				tenancyId:'',
			};
		},
		onLoad(routerParams) {
			this.tenancyId = routerParams.tenancyId
			this.getContractInfo();
		},
		methods:{
			async getContractInfo(){
				uni.showLoading({
					mask:true
				})
				let query = `tenancyId=${this.tenancyId}`
				const res = await findContract(query)
				try{
					if(res?.data.code == 200){
						this.content = res.data.data.contract
						this.signImage = res.data.data.contractPicUrl
						this.date = res.data.data.signTime
						uni.hideLoading()
						this.$refs.uReadMore.init();
					}else{
						uni.$u.toast(res.data.msg)
					}
				}catch(e){
					//TODO handle the exception
					uni.$u.toast(e)
					throw e
				}
			},
		}
	}
</script>

<style lang="scss" scoped>
	.border-line{
		border-bottom: 1rpx solid rgba(0, 0, 0, 0.12);
	}
.container{
	background-color: #ffffff;
	box-shadow: 2rpx 2rpx 6rpx 2rpx #eeeeee;
	padding: 30rpx 40rpx 0 40rpx;
	.contract-container{
		.contract-title{
			font-size: 32rpx;
			font-weight: 500;
			font-family: 'Franklin Gothic Medium', 'Arial Narrow', Arial, sans-serif;
			margin-bottom: 33rpx;
		}
		.content{
			padding-bottom: 46rpx;
		}
	}
	.sign-container{
		display: flex;
		align-items: center;
		padding: 5rpx;
	}
	.date-container{
		line-height: 72rpx;
	}
}
</style>
